package com.one.rope.mvp.web.common.dto.admin.partner;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.one.rope.mvp.basecore.util.StringUtils;
import com.one.rope.mvp.web.common.cache.GlobalCacheDataObject;
import com.one.rope.mvp.web.common.enums.CompanyPartnerTypeEnum;
import com.one.rope.mvp.web.common.enums.WorkFormEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

/**
 * @author Weijian.Liu
 * @desc 合伙人列表返回
 * @date 2020/2/23 1:49
 */
@Data
@ApiModel
public class AdminCompanyPartnerListVO {

  @ApiModelProperty(value = "合伙人id")
  private Long id;

  @ApiModelProperty(value = "岗位名称")
  private String name;

  @ApiModelProperty(value = "合伙人类型(1：事业合伙人 2：资金合伙人 3：顾问合伙人 4：资源合伙人)")
  @JsonProperty("partner_type")
  private Integer partnerType;

  @ApiModelProperty(value = "合伙人类型")
  @JsonProperty("partner_type_str")
  private Integer partnerTypeStr;

  @ApiModelProperty(value = "省编码")
  @JsonIgnore
  private String provinceCode;

  @ApiModelProperty(value = "市编码")
  @JsonIgnore
  private String cityCode;

  @ApiModelProperty(value = "所在城市")
  @JsonProperty("area_name")
  private String areaName;

  @ApiModelProperty(value = "所属项目")
  @JsonIgnore
  private Long projectId;

  @ApiModelProperty(value = "所属项目")
  @JsonProperty("project_name")
  private String projectName;

  @ApiModelProperty(value = "工作形态(1：全职 2：兼职 3：外包)")
  @JsonProperty("work_form")
  private Integer workForm;

  @ApiModelProperty(value = "工作形态")
  @JsonProperty("work_form_str")
  private String workFormStr;

  @ApiModelProperty(value = "创建时间")
  @JsonProperty("create_time")
  private Date createTime;

  public String getPartnerTypeStr() {
    if (null != partnerType) {
      return CompanyPartnerTypeEnum.getName(partnerType);
    }
    return "";
  }

  public String getAreaName() {
    String provinceName = "";
    String cityName = "";
    if (!StringUtils.isNullOrEmpty(provinceCode)) {
      provinceName = GlobalCacheDataObject.getArea(provinceCode).getAreaName();
    }
    if (!StringUtils.isNullOrEmpty(cityCode)) {
      cityName = GlobalCacheDataObject.getArea(cityCode).getAreaName();
    }
    return provinceName + cityName;
  }

  public String getWorkFormStr() {
    if (null != workForm) {
      return WorkFormEnum.getName(workForm);
    }
    return "";
  }

}
